package com.ruoyi.system.service.impl;

import com.ruoyi.system.mapper.GoodsLogisticsMapper;
import com.ruoyi.system.domain.GoodsLogistics;
import com.ruoyi.system.service.GoodsLogisticsService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (GoodsLogistics)表服务实现类
 *
 * @author makejava
 * @since 2020-10-28 14:37:53
 */
@Service("goodsLogisticsService")
public class GoodsLogisticsServiceImpl implements GoodsLogisticsService {
    @Resource
    private GoodsLogisticsMapper goodsLogisticsDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public GoodsLogistics queryById(Integer id) {
        return this.goodsLogisticsDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<GoodsLogistics> queryAllByLimit(int offset, int limit) {
        return this.goodsLogisticsDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param goodsLogistics 实例对象
     * @return 实例对象
     */
    @Override
    public GoodsLogistics insert(GoodsLogistics goodsLogistics) {
        this.goodsLogisticsDao.insert(goodsLogistics);
        return goodsLogistics;
    }

    /**
     * 修改数据
     *
     * @param goodsLogistics 实例对象
     * @return 实例对象
     */
    @Override
    public GoodsLogistics update(GoodsLogistics goodsLogistics) {
        this.goodsLogisticsDao.update(goodsLogistics);
        return this.queryById(goodsLogistics.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.goodsLogisticsDao.deleteById(id) > 0;
    }

    /**
     * 根据订单 Id 查询物流
     */
    @Override
    public GoodsLogistics queryByOrderId(String orderId) {
        return this.goodsLogisticsDao.queryByOrderId(orderId);
    }
}
